/**
 * @version 2007-5-16
 * @author xalinx at gmail dot com
 */
package org.nanhill.commons.dbutil.pagequery;

import java.io.Serializable;
import java.util.List;

/**
 * @version 2007-5-16
 * @author xalinx at gmail dot com
 * 
 */
public class BasePage<E> implements Serializable {
	private static final long serialVersionUID = 8176623225942805055L;

	private PageQuery pageQuery;

	/**
	 * total Items count.
	 */
	private int count;

	/**
	 * Items of this page.
	 */
	private List<E> items;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getCurrentPage() {
		if (count == 0) {
			return 0;
		}
		return count / pageQuery.getPageSize() + 1;
	}

	public List<E> getPage() {
		return items;
	}

	public void setItems(List<E> items) {
		if (null == items) {
			throw new IllegalArgumentException();
		}
		this.items = items;
	}

	public int getPageSize() {
		return pageQuery.getPageSize();
	}

	public int getStart() {
		return pageQuery.getStart();
	}

	public BasePage() {
	}

	public BasePage(PageQuery query, List<E> items) {
		this.pageQuery = query;
		this.items = items;
	}

}
